<div class="cpanel-link-management" ng-app="linkManagementApp" ng-controller="linkManagementController">
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" ng-disabled="!bulk_actions_enabled()"
            data-toggle="dropdown" aria-expanded="false">
    Bulk actions <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
      <li><a href="#">Copy selected to ...</a></li>
      <li><a href="#">Move selected to ...</a></li>
      <li><a href="#" data-toggle="modal" data-target="#cpanelLinkModalRemoval">Remove selected</a></li>
    </ul>
  </div>

  <div class="table-responsive">
    <table class="table table-striped tb-link-management">
      <thead>
      <tr>
        <th><input type="checkbox" class="checkbox-all" /></th>
        <th>Link</th>
        <th>Board</th>
        <th colspan="2">Actions</th>
      <tr>
      </thead>
      <tbody class="cpanel-link-management-list">
        <tr dir-paginate="nip in nips | itemsPerPage: nips_per_page" total-items="nips_count">
          <td><input type="checkbox" value="{{ nip.nid }}" class="checkbox-nip" /></td>
          <td><a href="{{ nip.url }}">{{ nip.og_data.title || nip.og_data.url }}</a></td>
          <td><a href="{{ nip.board.url }}">{{ nip.board.name }}</a></td>
          <td class="action">
            <a href="/node/{{ nip.nid }}/edit?destination=cpanel/link-management">
              <?php print CommonHelper::crabii_icon('pencil') ?>
            </a>
          </td>
          <td class="action">
            <a href="#" ng-click="delete_nip(nip)" data-toggle="modal" data-target="#cpanelLinkModalRemoval">
              <?php print CommonHelper::crabii_icon('trash-o'); ?>
            </a>
          </td>
        </tr>
      </tbody>
    </table>

    <dir-pagination-controls
      on-page-change="page_changed(newPageNumber)"
      template-url="<?php print '/sites/all/libraries/bower_components/angular-utils-pagination' ?>/dirPagination.tpl.html">
      </dir-pagination-controls>
  </div>

  <div class="modal fade" id="cpanelLinkModalRemoval" tabindex="-1" role="dialog" aria-labelledby="cpanelLinkModalRemovalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
          <h4 class="modal-title" id="cpanelLinkModalRemovalLabel">Confirm link removal</h4>
        </div>
        <div class="modal-body">
          <p>Are you sure you want to remove following link(s):</p>
          <p>
            <ul>
              <li ng-repeat="nip in nips_selected">{{ nip.og_data.title || nip.og_data.url }}</li>
            </ul>
          </p>
        </div>
        <div class="modal-footer clearfix">
          <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary pull-right" ng-click="delete_nips()">Remove</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->
</div>
